from likeshop_project.base.mybase import Tools
from likeshop_project.accountapi.login_api import login_model

class add_shipping_address_model(Tools):
    path = '/api/user_address/add'
    def add_shipping_address_action(self,contact,telephone,province_id,city_id,district_id,address,hb,is_default=0,):
        mydata= {
            'contact':contact,
            'telephone':telephone,
            'province_id':province_id,
             'city_id':city_id,
            'district_id':district_id,
            'address':address,
            'is_default':is_default
        }
        res = self.huihua.post(url=self.hosturl+self.path,data=mydata,headers=hb)
        return res.json()


if __name__ == '__main__':

    import requests
    s = requests.session()
    re = login_model(huihua=s)
    mag = re.login_action(account='17909898989',password='123wqewqrf')
    gettoken = mag['data'].get('token')
    hb = {'token':gettoken}
    re = add_shipping_address_model(huihua=s)
    msg =re.add_shipping_address_action(contact='张三',telephone='17909898989',province_id='130000',city_id='130200',district_id='130283',address='八里街',hb=hb)
    print(msg)